package Collection;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class SetDemo {
    public static void main(String[] args) {
        List<String>list=new ArrayList<>();
        list.add("one");
        list.add("two");
        list.add("three");
        list.add("four");
        list.add("five");
        list.add("two");
        System.out.println("list:"+list); //[one, two, three, four, five, two]


        //去重
        Set<String>set=new HashSet<>();
        set.addAll(list);
        System.out.println("set:"+set); //[four, one, two, three, five]









        /*
        Set<String>set =new HashSet<>();
        set.add("one");
        set.add("two");
        set.add("three");
        set.add("four");
        set.add("five");
        set.add("two");
        System.out.println(set);
         */
    }
}
